package main

import "fmt"

type Person struct {
	name string
	age  int
	sex  string
}

func NewPerson(name string, age int, sex string) *Person {
	return &Person{
		name: name,
		age:  age,
		sex:  sex,
	}
}

/**
	func(接收者变量 接收者类型) 方法名(参数列表) (返回参数) { body }
**/

func (p *Person) SetName(name string) {
	p.name = name
}

func (p Person) PrintPerson() {
	fmt.Printf("Name: %s, Age: %d, Sex: %s\n", p.name, p.age, p.sex)
}

func main() {
	p := Person{}
	p.name = "Alice"
	p.age = 25
	p.PrintPerson()
	p2 := p
	// p2.name = "Bob"
	// p2.sex = "Male"
	p2.SetName("Bob")
	p2.PrintPerson()
	// 结构体是值类型
	p.PrintPerson()
}
